// rem适配
let suitable_aging = 1;

const getWidth = () => {
  return window.innerWidth > 750 ? 600 : window.innerWidth;
};

export const setFontSize = () => {
  const htmlElement = document.documentElement;
  // htmlElement.style.fontSize = (window.innerWidth / 100) * suitable_aging + 'px';
  // htmlElement.style.fontSize = 1 * suitable_aging * (window.innerWidth / 375) + 'px';
  htmlElement.style.fontSize = 1 * suitable_aging * 100 * (getWidth() / 375) + 'px';
};

// window.__setFontSize = setFontSize;
setFontSize();

const mata = document.getElementById('meta1px');

mata.content = `width=device-width,user-scalable=no,initial-scale=${1 / window.devicePixelRatio}`;
// mata.content = `width=device-width,user-scalable=no,initial-scale=${1}`;
// mata.content = `width=device-width,user-scalable=no`;

window.addEventListener('resize', () => {
  setFontSize();
});

export const setSuitableAging = (size: number) => {
  suitable_aging = size;
  setFontSize();
};

// 是否是适老化模式
export const isSuitableAging = () => {
  return suitable_aging !== 1;
};
